<script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.form.js"></script>
<script>
// prepare the form when the DOM is ready 
$(document).ready(function() { 
    var options = {
        url: '{% url choice_create poll.pk %}?ajax=1',
        success:  showResponse  // post-submit callback 
    }; 
 
    // bind to the form's submit event 
    $('#ajax-form').submit(function() { 
        // inside event callbacks 'this' is the DOM element so we first 
        // wrap it in a jQuery object and then invoke ajaxSubmit 
        $(this).ajaxSubmit(options); 
        // always return false to prevent standard browser submit and page navigation 
        return false; 
    }); 
}); 
 
// post-submit callback 
function showResponse(responseText, statusText)  { 
    $('#choices').append(responseText);
    tb_remove();
} 
</script>
<form id="ajax-form" action="{% url choice_create poll.pk %}" method="post">
    <ul>
        {{ form.as_ul }}
    </ul>
    <input type="submit" value="Add Choice" />
</form>
